import 'dart:async';

import 'package:fate_blind_box/chat_view/chat_page_controller.dart';
import 'package:fate_blind_box/im/msg_content.dart';
import 'package:fate_blind_box/im/video_model.dart';
import 'package:fate_blind_box/model/chat_friend_message_entity.dart';
import 'package:flutter/material.dart';
import 'package:flutter_sound/public/flutter_sound_player.dart';
import 'package:flutter_sound/public/flutter_sound_recorder.dart';
import 'package:flutter_sound/public/tau.dart';
import 'package:get/get.dart';
import 'package:im_flutter_sdk/im_flutter_sdk.dart';
import 'package:just_audio/just_audio.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

class ChatState {
  var backColors = Colors.blue.obs;

  ChatPageController chatPageController = Get.put(ChatPageController());

  /// tag
  var tag = 'ChatLogic';

  /// 用户名
  var nickName = ''.obs;

  /// 用户头像
  var avatarUrl = ''.obs;

  /// 会话Id
  String conversationId = '';

  /// 会话
  EMConversation? conversation;

  /// 消息列表
  RxList<EMMessage> messageList = <EMMessage>[].obs;

  /// 好友信息
  var userInfoList = <EMUserInfo>[].obs;

  /// 当前好友信息
  Rx<ChatFriendMessageEntity?> model = Rx(null);

  /// 是否正在下载
  var isDownload = false.obs;

  ScrollController controller = ScrollController();

  // 是否有更多
  var hasMore = false.obs;
  RefreshController refreshController =
      RefreshController(initialRefresh: false);

  /// 是否显示表情
  var emojiShowing = false.obs;

  /// 是否可以发送消息
  var canSend = false.obs;
  String centext = '';

  var isShow = false.obs;

  final TextEditingController messController = TextEditingController();
  final FocusNode focusNode = FocusNode();

  // 判断是否弹出键盘
  var keyboardVisible = false.obs;

  final GlobalKey formKey = GlobalKey<FormState>();

  ///  声音播放器
  FlutterSoundRecorder recorderModule = FlutterSoundRecorder();
  FlutterSoundPlayer playerModule = FlutterSoundPlayer();
  FlutterSound sound = FlutterSound();
  final player = AudioPlayer();

  RecordPlayState state = RecordPlayState.record;

  VideoModel videoModel = VideoModel();

  final int maxLength = 600;

  var num = 0;
  String path = "";

  bool isStop = true;

  String voiceIco = "images/voice_volume_7.png";

  final List<String> assetList = [
    "images/voice_volume_1.png",
    "images/voice_volume_2.png",
    "images/voice_volume_3.png",
    "images/voice_volume_4.png",
    "images/voice_volume_5.png",
    "images/voice_volume_6.png",
    "images/voice_volume_7.png",
  ];

  List<String> emojiList = [];

  StreamSubscription? subscription;

  ChatState() {
    ///Initialize variables
  }
}
